<?php

namespace Services\Sys\Models;

use Helpers\BaseModel;

class XhsysTree extends BaseModel
{

    /**
     *
     * @var integer
     */
    public $iNodeId;

    /**
     *
     * @var string
     */
    public $sNodeName;

    /**
     *
     * @var string
     */
    public $sNodeShortName;

    /**
     *
     * @var string
     */
    public $sNodeIcon;

    /**
     *
     * @var integer
     */
    public $iParentNodeId;

    /**
     *
     * @var integer
     */
    public $iNodeType;

    /**
     *
     * @var integer
     */
    public $bDelete;

    /**
     *
     * @var string
     */
    public $tCreateDate;

    /**
     *
     * @var string
     */
    public $iCreateUserId;

    /**
     *
     * @var string
     */
    public $tLastModifyDate;

    /**
     *
     * @var string
     */
    public $iLastModifyUserId;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        parent::initialize();
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHSys_Tree';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhsysTree[]|\Phalcon\Mvc\Model\ResultsetInterface
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhsysTree|\Phalcon\Mvc\Model
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    public function beforeSave()
    {
        if (!$this->iParentNodeId) {
            $this->iParentNodeId = 0;
        }
        if (!$this->iNodeType) {
            $this->iNodeType = 2;
        }
        return true;
    }
}
